/**
 * Created by Administrator on 2016/8/4.
 */

var position_name,position_code,department_Id, currentID, flag = true;
function Personload() {
    $('#table').bootstrapTable({
        method: "get",
        striped: true,
        singleSelect: true,
        url:"position.json",
        dataType: "json",
        pagination: true, //分页
        pageSize: 10,
        pageNumber: 1,
        search: false, //显示搜索框
        contentType: "application/x-www-form-urlencoded",
        queryParams: null,
        columns: [
        	{
                checkbox:"true",
                field: 'id',
                align: 'center',
                valign: 'middle'
            },
            /*{
                visible:false,//隐藏列
                field: 'id',
                align: 'center',
                valign: 'middle'
            },*/
            {
                title: "职位编码",
                field: 'position_code',
                align: 'center',
                valign: 'middle'
            },
            {
                title: '职位名称',
                field: 'position_name',
                align: 'center',
                valign: 'middle'
            },
            {
                title: '职位分类',
                field: 'posClassName',
                align: 'center'
            },
            {
                title: '所属部门',
                field: 'department',
                align: 'center'
            },
                     
            {
                title: '操作',
                field: 'id',
                align: 'center',
                formatter: function (value, row) {
                	var e = '<a href="#" onclick="del(\'' + row.id + '\')">删除</a> '
                    var d = '<a href="#" onclick="edit(\'' + row.id + '\')">编辑</a> ';
                    var g = '<a href="#" onclick="show(\'' + row.id + '\')">明细</a> '
                    return e + d + g;
                }
            }
        ]
    });
    getData();
}
function getData() {
    
	position_name = $("#position_name").val();
    position_code = $("#position_code").val();
    department_Id = $("#department_Id").val();
    
    $.ajax({
        type: "GET",
        url: "select_position.json",
        data:{
        	"position_name":position_name,
        	"position_code":position_code,
        	"department_Id":department_Id
        },
        dataType: "json",
        success: function (result) {
            if (result.data) {
                var TableData = result.data;
                $('#table').bootstrapTable("load", TableData);
            }
        }
    })
}
function addPos(){
	alert("进入添加函数了！！");
	
	
   
    alert("ajax!");
    $.ajax({
        type: "GET",
        url: "select_position.json",
        data:{
        	"position_name":position_name,
        	"position_code":position_code,
        	"department_Id":department_Id
        },
        dataType: "json",
        success: function (result) {
            if (result.data) {
                var TableData = result.data;
                $('#table').bootstrapTable("load", TableData);
            }
        }
    })
}
function del(id) {
    alert(id)
    var NoticeId = id;
    $.ajax({
        url: '../WorkRecord/DeleteWork?workId=' + NoticeId,
        type: 'GET',
        dataType: 'json',
        success: function (data) {
            if (data.data) {
                alert("删除成功！")
                getData();
            } else {
                alert("删除失败")
            }
        },
        error: function (err) {
        }
    });
}
function getCurrentID() {
    return currentID;
}
function openlayer(id){
    layer.open({
        type: 2,
        title: '添加信息',
        shadeClose: true,
        shade: 0.5,
        skin: 'layui-layer-rim',
//            maxmin: true,
        closeBtn:2,
        area: ['80%', '90%'],
        shadeClose: true,
        closeBtn: 2,
        content: 'person_tail.html'
        //iframe的url
    });
}





